<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty trimwhitespace outputfilter plugin
 *
 * File:     outputfilter.manage.php<br>
 * Type:     outputfilter<br>
 * Name:     bar<br>
 * @param string
 * @param Smarty
 */
function smarty_outputfilter_manage($source, &$smarty)
{
    @header('Content-Type: text/html; charset=utf-8');
    if ($_SERVER['HTTP_HOST'] == substr(HOST_MANAGE, 7)) {
        $source = preg_replace_callback('/(href|action)\=[\"|\'](index\.php)?(?:\?(.*?))?[\"|\']/', 'smarty_outputfilter_manage_link', $source);
        $source = preg_replace_callback('/(href|action)\=[\"|\']('. addcslashes( HOST_MANAGE , '/') .')\/\?(.*)[\"|\']/', 'smarty_outputfilter_manage_link', $source);
    }
    return $source;
}
if (!function_exists('smarty_outputfilter_manage_link')){
	function smarty_outputfilter_manage_link($matched){
		if ($matched[3]) {
		    return $matched[1].'="'. HOST_MANAGE . '/'. B::i()->plugin->request->urlformat($matched[3]) .'"';
		} else {
	        $action = B::i()->plugin->request->data(B::i()->config->action);
            return $matched[1].'="'. HOST_MANAGE .'/a='. $action. '/"';
		}
	}
}
?>
